home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / -in_the_mag- / multitasking / feature / quantum / quantum.doc < prev    next >
Text File  |  2000-03-05  |  13KB  |  355 lines

  1.         _   ********************************************************     _
  2.      _ //    ***  Quantum V1.1, © Mathias Karlsson 20 Okt 1997  ***   _ //
  3.      \X/      **   Changes the quantum time slice in ExecBase   **    \X/
  4.                **************************************************
  5.  
  6. DISTRIBUTION:
  7. ¯¯¯¯¯¯¯¯¯¯¯¯¯
  8.     I (Quantum) am freely distributable as long as the following conditions
  9.     and terms are fulfilled:
  10.  
  11.         o   All my files in this archive must remain unmodified.
  12.  
  13.                 Quantum/Quantum
  14.                 Quantum/Quantum.info
  15.                 Quantum/Quantum12
  16.                 Quantum/Quantum.doc
  17.                 Quantum/Quantum.doc.info
  18.                 Quantum/Quantum.guide
  19.                 Quantum/Quantum.guide.info
  20.                 Quantum.info
  21.                 Quantum.readme
  22.                 Quantum.readme.info
  23.  
  24.         o   If any files are added to me, it must be obvious that
  25.             they do not belong to the original distribution, and NO files
  26.             may be added (or removed) to the Quantum directory!
  27.  
  28.             So called "BBS ads" may NEVER be added! I hate them!
  29.  
  30.         o   I MAY be repacked with LZX or other more efficient Amiga
  31.             archivers, but my directory structure must remain intact.
  32.  
  33.             So called "BBS ads" may NEVER be added! Did I say I hate them?
  34.  
  35.         o   The copying is done on a non-commercial basis.
  36.             A small fee to cover media costs etc. may be charged.
  37.  
  38. *READ >>>   If you put me on a CD or coverdisks etc My Creator would
  39. *THIS >>>   appreciate a copy of the disk (magazine?),but it's _not_ required.
  40.  
  41.         o   Aminet and Fred Fish can distribute me in any way they want.
  42.  
  43.         o   Copy me. I want to travel!
  44.  
  45. PURPOSE:
  46. ¯¯¯¯¯¯¯¯
  47.     By changing the exec quantum time slice value you may in some cases
  48.     get a 'snappier' computer and speed increases when multitasking, because
  49.     the speed of exec taskswitching is increased.
  50.  
  51.     I, Quantum, can do that.
  52.  
  53.         Q:  Why? How? And what is a quantum anyway?
  54.         A:  Read this document. Especially "How it works".
  55.  
  56. REQUIREMENTS:
  57. ¯¯¯¯¯¯¯¯¯¯¯¯¯
  58.     Any Amiga. I use no memory after the exec quantum has been modified.
  59.  
  60.     I, Quantum, being highly sofisticated, requires OS2+, and can be started
  61.     both from Workbench and CLI. I will just exit if run under OS1.x,
  62.     printing "You need OS2+" or something.
  63.  
  64.     My low-life brother, Quantum12, runs on any Amiga, but is CLI-only, ha!
  65.  
  66.     We both prefer 68020+, and fastmem is recommended, but _not_ needed.
  67.  
  68.         Q:  Why is "Quantum12" 5x larger than "Quantum"?
  69.         A:  Because My Creator wrote that version in 5 minutes and used
  70.             standard stdio (printf() etc). Live with it. You should all
  71.             have upgraded to OS2+ anyway. Your Amiga deserves it.
  72.  
  73.     I have been tested on these configurations:
  74.  
  75.     Amiga 500 KS2.04 with and without 68030
  76.     Amiga 500 KS3.1  with and without 68030
  77.     Amiga 1200 KS3.0 with and without 68030 + MMU
  78.     Amiga 4000/040 KS3.1 running Enforcer etc.
  79.  
  80.     Quantum12 has been tested on My Creators old Amiga 500 running KS1.3
  81.  
  82. USAGE:
  83. ¯¯¯¯¯¯
  84.     From CLI:       I, Quantum, can be run with or without arguments.
  85.                     If no arguments are given, the current value
  86.                     of the exec quantum is printed.
  87.  
  88.                     1:> Quantum
  89.                     Quantum 1.0 © Mathias Karlsson 1996
  90.                     Quantum:4
  91.                     1:>
  92.  
  93.                     And if you feed me a number I will try to change the
  94.                     exec quantum to that value.
  95.  
  96.                     It can be any number from 1 (fastest) to 255 (slowest).
  97.                     4 is default under OS2-3.
  98.  
  99.                     My Creator say it is possible to change the Quantum
  100.                     to any value between 0 and 65535 ('UWORD'), but that
  101.                     the need for so high numbers are (virtually) zer0.
  102.  
  103.                     1:> Quantum 2
  104.                     Quantum 1.0 © Mathias Karlsson 1996
  105.                     Quantum:2
  106.                     1:>
  107.  
  108.                     If you want to run me every time you boot your computer,
  109.                     and why wouldn't you, you can put me in your
  110.                     s:startup-sequence or s:User-Startup.
  111.  
  112.                     Just add this line:
  113.  
  114.                     Quantum >nil: 1
  115.  
  116.                     anywhere in s:startup-sequence or s:User-Startup.
  117.  
  118.                     Adding me early to the startup-sequence made My Creators
  119.                     (1min+) startup 5-10% faster.
  120.  
  121.                     Quantum12 works in the same way.
  122.  
  123. -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
  124.  
  125. From WorkBench:     Easy. Just dump me in sys:wbstartup. Or doubleclick me.
  126. (only 'Quantum')
  127.                     But first you may want to have a look at the tooltypes
  128.                     in the Quantum icon. Select an icon and 'Information'
  129.                     in the Workbench menu. You will find three tooltypes:
  130.  
  131.                     QUANTUM=1
  132.                     (SHOW)
  133.                     DONOTWAIT
  134.  
  135.                     QUANTUM=1  is of course the new exec quantum value.
  136.                                It can be any number from 1 (fastest)
  137.                                to 255 (slowest). 4 is default under OS2-3.
  138.  
  139.                     (SHOW)     If you remove the parentheses (=activates)
  140.                                a small requester will pop-up and show
  141.                                the current value of the exec quantum.
  142.  
  143.                     DONOTWAIT  Tells Workbench not to wait for it in
  144.                                the WBStartup. Do not touch.
  145.  
  146.                     Quantum12, the Kickstart 1.2-1.3 version, can not
  147.                     be run from Workbench, it will just exit, doing
  148.                     nothing. Ha! Upgrade!
  149.  
  150. *UGLY               Unfortunately, My Creator is not a painter, and
  151. *ICON               my icon look pretty ugly. I deserve better!
  152.  
  153. *FAME               If you send My Creator a better looking icon I'm
  154. *AND                sure he'll include it in the next release!
  155. *GLORY              And give eternal fame and glory to _you_ of course:-)
  156.                     If you send me a 'NewIcon' icon please send an
  157.                     iff-picture too, My Creator doesn't have
  158.                     NewIcons installed and seeing the icon before
  159.                     spreading it all over the world would be nice...:)
  160.  
  161. DISCLAIMER:
  162. ¯¯¯¯¯¯¯¯¯¯¯
  163.     I am a hack. I modify data in ExecBase! Viruskillers and system
  164.     testing software may report me! Mohahahahahahahaaaaa!!!
  165.  
  166.     Some people say you should never ever never change anything in ExecBase.
  167.  
  168.     Don't listen to them;-)
  169.  
  170.     Changing quantum should not cause any problems on any Amiga running
  171.     KS1.2-3.1, and probably not in future versions either.
  172.  
  173.     But you have been warned.
  174.  
  175.     The SOURCE [4323 bytes], in Dice C, IS available upon request.
  176.  
  177. HOW IT WORKS:
  178. ¯¯¯¯¯¯¯¯¯¯¯¯¯
  179.     First you must know how multitasking works on the Amiga.
  180.  
  181.     This info can be found in RKRM if anyone is interested, but
  182.     here is a brief (well...) introduction:
  183.  
  184.     --
  185.     The Amiga's multitasking works by switching which task is currently
  186.     using the CPU. Each task has a priority assigned to it. Exec will let
  187.     the task with the highest priority use the CPU, but only if the task
  188.     is _ready_ to run.
  189.  
  190.     A task can be in one of three states: 'ready', 'sleeping' or 'running.'
  191.  
  192.     A 'ready' task is not currently using the CPU, but is waiting to use
  193.     the processor. Exec keeps and sorts a list of the 'ready' tasks so it
  194.     easily can find the 'ready' task with the highest priority, and 'run' it.
  195.  
  196.     A 'sleeping' task is not currently 'running', and is waiting for some
  197.     event (keypress, mouseclick etc) to happen, and then Exec will move the
  198.     'sleeping' task into the list of 'ready' tasks.
  199.  
  200.     A 'running' task is currently using the CPU, and will remain the current
  201.     task until one of three things occur:
  202.  
  203.     o   A higher priority task becomes ready, so the OS preempts the current
  204.         task and switches to the higher priority task.
  205.  
  206.     o   The currently running task needs to wait for an event, so it goes to
  207.         sleep and Exec switches to the highest priority task in Exec's ready
  208.         list.
  209.  
  210.     o   The currently running task has control of the CPU for at least a
  211.         preset time period called a quantum and there is another task with
  212.         equal priority ready to run. In this case, Exec will preempt the
  213.         current task for the ready one with the same priority.
  214.  
  215.         This is known as time-slicing.
  216.  
  217.         When there is a group of tasks of equal priority on the top of the
  218.         ready list, Exec will cycle through them, letting each one use
  219.         the CPU for a quantum (a slice of time).
  220.  
  221.         This will result in a time-sequenced 'round robin' scheduling of
  222.         all equal-priority tasks.
  223.  
  224. *NOTE   In KS1.3 (and probably 1.2 as well), there is a bug in Exec,
  225.         that causes a taskswitch after each interrupt, even if the whole
  226.         quantum isn't used. This mean that under certain conditions (well,
  227.         pretty much most of the time...:) changing the quantum from 16 to 4
  228.         or 255 or even 65535 or 1 won't make much (if any) difference.
  229.  
  230.         Well, who cares. It won't hurt either.
  231.  
  232.         Upgrade thy OS.
  233.  
  234.     --
  235.  
  236.         Q: So. What's the problem with this?
  237.  
  238.         A: Well, if you have many time-consuming tasks running at the same
  239.            priority the computer will feel sluggish and slow.
  240.  
  241.            Even if it is an Amiga. I try to speed things up.
  242.  
  243.     Generally speaking, time-consuming and/or number-crunching programs
  244.     such as raytracers or compilers should be set to lower priority
  245.     to eliminate this problem, but some programs won't let you change
  246.     priorities (or screw up if you change them anyway) so I, Quantum,
  247.     may, in some cases, make the computer feel faster and more responsive.
  248.  
  249.     The default quantum for OS2.04-3.1 is _4_, and for OS1.3 _16_ (I think).
  250.  
  251.     Generally speaking, changing the quantum to a LOWER value will speed
  252.     up taskswitching and practical usage, in THEORY a HIGHER value may give
  253.     numbercrunching programs (raytracers etc) a (small) boost because
  254.     fewer taskswitchs are needed. Go ahead and experiment! (send me results!)
  255.  
  256.     My Creator read somwhere that 68030/040s have no problem with a quantum
  257.     of 1 and tests made by myself and him on his 40MHz 030 supports
  258.     that theory.
  259.  
  260.     Of course slower Amigas may benefit from me too.
  261.  
  262.     I am the Greatest!
  263.  
  264.     I do Magic!
  265.  
  266.     I am Quantum!
  267.  
  268.     Oh, did I mention I was humble too?
  269.  
  270. TESTING:
  271. ¯¯¯¯¯¯¯¯
  272.     TEST 1:
  273.     (compiling a rather large c-source file, and having three other tasks
  274.      busywaiting at the same priority. Stupid, but hey, this is a test...:)
  275.  
  276.     Quantum is:1
  277.     12-> time dmake -a
  278.     DMAKE Done.
  279.     Execution time: 44.948498 s.
  280.  
  281.     Quantum is:4    [default OS2 & OS3]
  282.     12-> time dmake -a
  283.     DMAKE Done.
  284.     Execution time: 116.703899 s.
  285.  
  286.     Quantum is:16   [default KS1.2 & 1.3]
  287.     12-> time dmake -a
  288.     DMAKE Done.
  289.     Execution time: 189.556968 s.
  290.  
  291.     TEST 2:
  292.     (having one other task busywait and testing 'dir c:' with 300+ files)
  293.  
  294.     Quantum is:1
  295.     12-> timenil dir c:
  296.     Execution time: 14.966172 s.
  297.  
  298.     Quantum is:4    [default OS2 & OS3]
  299.     12-> timenil dir c:
  300.     Execution time: 35.418734 s.
  301.  
  302.     Quantum is:16   [default KS1.2 & 1.3]
  303.     12-> timenil dir c:
  304.     Execution time: 49.001525 s.
  305.  
  306.     Well. My Creator didn't bother to make any more tests, but if you
  307.     use me and make other interesting tests and/or get funny/interesting
  308.     results from using me, go ahead, mail My Creator.
  309.  
  310. NOTE: If you are running Executive (GREAT program!) you can not do
  311.     tests like this, because Executive will lower the priority of those
  312.     Busy-Waiting or numbercrunching tasks.
  313.     So, if you are using Executive and set a quantum of 1 you will
  314.     not notice a big difference in performance, if any.
  315.     But the computer may feel 'snappier'.
  316.  
  317.     The Queue-scheduler of Executive adjusts the Quantumvalue BTW. Nice.
  318.  
  319. ACKNOWLEDGMENTS:
  320. ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  321.     Icon for me (Quantum) is made by Frank Stohl and severely modified
  322.     by my creator.
  323.     Icon for the drawer is made by Martin Huttenloher.
  324.     Icon for documentation is made by Frank Bernard.
  325.  
  326.     Dice C and Black's Editor ('BED') were used during development.
  327.  
  328.     Music played while programming and writing docs:
  329.  
  330.             Iron Maiden
  331.             Kraftwerk
  332.             Manowar
  333.             Rob Hubbard (PlaySID)
  334.             ABBA
  335.             Beethoven
  336.             and more...
  337.  
  338. FINAL WORDS:
  339. ¯¯¯¯¯¯¯¯¯¯¯¯
  340.         Q: Why the h*ck is this documentation so LONG, it's a tiny program?
  341.         A: I don't know. You tell me. Probably My Creator was bored or
  342.            on drugs or something when he wrote this monster documentation
  343.            for a 1K program...
  344.  
  345.         [Creators note: Both. Both.]
  346.  
  347. HISTORY:
  348. ¯¯¯¯¯¯¯¯
  349.     V 1.0   First public release.
  350.     V 1.1   971020 -rewrote some parts of the code.
  351.  
  352. CONTACT:
  353. --------
  354. e-mail:I have several addresses, but they may change in the future so I
  355.        recommend this one: md7karma@mdstud.chalmers.se for the moment.